<extend name="admin/main"/>

<block name="title">
    <title>关于我们</title>
</block>

<block name="css">
</block>

<block name="heading">关于我们</block>

<block name="content">
    <div class="panel panel-primary">
        <div class="panel-heading text-uppercase">introduction</div>
        <div class="panel-body">
            <table class="table table-bordered table-hover text-center">
                <thead>
                <tr class="text-uppercase">
                    <th class="text-center">#</th>
                    <th class="text-center">type</th>
                    <th class="text-center">title</th>
                    <th class="text-center">updated_at</th>
                    <th class="text-center">created_at</th>
                    <th class="text-center">action</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="data" item="item">
                    <tr data-id="{$item.id}">
                        <td>{$item.id}</td>
                        <td>{$item.type}</td>
                        <td>{$item.title}</td>
                        <td>{$item.updated_at}</td>
                        <td>{$item.created_at}</td>
                        <td>
                            <div class="btn-group">
                                <a class="btn btn-success-alt btn-sm edit"
                                   href="/admin/setting/introduction/edit?id={$item.id}">
                                    <i class="fa fa-edit"></i>
                                </a>
                                <button class="btn btn-danger-alt btn-sm delete"><i class="fa fa-trash"></i></button>
                            </div>
                        </td>
                    </tr>
                </foreach>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="12" class="text-left">
                        <a class="btn btn-sky-alt btn-sm" href="/admin/setting/introduction/add">
                            <i class="fa fa-upload"></i> 创建
                        </a>
                    </td>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</block>

<block name="js">
    <script type="text/javascript" src="__PUBLIC__/assets/demo/demo.js"></script>
    <script type="text/javascript" src="__PUBLIC__/assets/demo/demo-switcher.js"></script>
    <script type="text/javascript" src="__PUBLIC__/assets/plugins/bootbox/bootbox.js"></script>
    <script src="__PUBLIC__/assets/plugins/form-pagedown/js/jquery.pagedown-bootstrap.combined.js"></script>
    <script>
        $(document).ready(function () {
            $('.delete').click(function () {
                var id = $(this).parents('tr').attr('data-id');
                bootbox.confirm('是否删除 ?', function (r) {
                    if (r === false) return false;
                    $.post('/admin/webSetting/deleteIntroduction', {id: id}, function (res) {
                        res = JSON.parse(res);
                        if (res.success === false) {
                            new PNotify({
                                title: 'Oh On!',
                                text: JSON.stringify(res.data),
                                type: 'error',
                                icon: 'ti ti-info-alt',
                                styling: 'fontawesome'
                            });
                        } else {
                            window.location.reload();
                        }
                    });
                });
            });
        });
    </script>
</block>
